home *** CD-ROM | disk | FTP | other *** search
- /* ========================================================================== */
- /* == Black Holes for Windows Effects DLL Demo == */
- /* == == */
- /* == (c) Datapath UK Ltd, Derby. == */
- /* == Last modified : July 1994 == */
- /* == == */
- /* == A 'simple' warp effect, which just changes the cursor to an arrow == */
- /* == pointing in the general direction of the exit hole, and moves == */
- /* == the cursor in a straight line. == */
- /* == == */
- /* == Effect is currently not configurable - could be altered so that == */
- /* == the DELAY_TIME comes from the config data, which could be altered == */
- /* == be altered by the user. == */
- /* == == */
- /* == NB : Since this is a very simple example, many of the parameters == */
- /* == in each routine is not used, and will probably produce many == */
- /* == 'Parameter 'xxxxxx' is never used' == */
- /* == type messages when compiled. == */
- /* == Your compiler may provide methods (eg compiler switches, or == */
- /* == #pragma directives) to prevent these messages. == */
- /* ========================================================================== */
-
- #include <string.h>
-
- #include "bheffect.h"
-
- #define DELAY_TIME 1000
-
- static HINSTANCE FXInstance;
-
- /*----------------------------------------------------------------------------*/
-
- static void CALLBACK move_cursor_line_dda (int xpos, int ypos, LPARAM delay)
- {
- int i;
- SetCursorPos (xpos, ypos);
- /* Wait for a while */
- for (i = 0; i < delay; i++);
- }
-
-
- /* ========================================================================== */
- /* == Simple effect - == */
- /* == has four cursors (diagonal arrows pointing NE, SE, SW & NW) == */
- /* == just moves cursor in straight line from entry to exit hole, no == */
- /* == 'begin_effect' or 'end_effect' == */
- /* ========================================================================== */
-
- #define POINTER_EFFECT "Simple Pointer"
-
- void pointer_begin_effect (PTWarpPoints wdata, HWND hwnd, TConfigData config, LPDWORD user_data )
- {
- /* do nothing for this particular effect */
- }
-
- void pointer_do_effect (PTWarpPoints wdata, HWND hwnd, TConfigData config, LPDWORD user_data)
- {
- LineDDA (wdata->start.x, wdata->start.y,
- wdata->end.x, wdata->end.y, move_cursor_line_dda, DELAY_TIME);
- }
-
- void pointer_end_effect (PTWarpPoints wdata, HWND hwnd, TConfigData config, LPDWORD user_data)
- {
- // do nothing for this particular effect
- }
-
- unsigned short pointer_load_cursor (HCURSOR FAR *cursors)
- {
- /* 8 arrows, pointing N, NE, E, SE, S, SW, W & NW respectively */
- cursors [0] = LoadCursor (FXInstance, "ARROW_U");
- cursors [1] = LoadCursor (FXInstance, "ARROW_TR");
- cursors [2] = LoadCursor (FXInstance, "ARROW_R");
- cursors [3] = LoadCursor (FXInstance, "ARROW_BR");
- cursors [4] = LoadCursor (FXInstance, "ARROW_D");
- cursors [5] = LoadCursor (FXInstance, "ARROW_BL");
- cursors [6] = LoadCursor (FXInstance, "ARROW_L");
- cursors [7] = LoadCursor (FXInstance, "ARROW_TL");
- return (8);
- }
-
- unsigned short pointer_select_cursor (PTWarpPoints pts)
- {
- /* select cursor which points in general direction of exit hole */
- /* from the entry hole */
- int delta_x, delta_y;
- delta_x = pts->end.x - pts->start.x;
- if (delta_x == 0) delta_x = 1;
- delta_y = pts->end.y - pts->start.y;
- if (delta_y == 0) delta_y = 1;
-
- if ((delta_x >= 0) && (delta_y >= 0))
- {
- if ((delta_y / delta_x) > 4)
- return (4);
- else if ((delta_x / delta_y) > 4)
- return (2);
- else
- return (3);
- }
- else if ((delta_x >= 0) && (delta_y < 0))
- {
- if ((-delta_y / delta_x) > 4)
- return (0);
- else if ( (-delta_x / delta_y) > 4)
- return (2);
- else
- return (1);
- }
- else if ((delta_x < 0) && (delta_y < 0))
- {
- if ((delta_y / delta_x) > 4)
- return (0);
- else if ((delta_x / delta_y) > 4)
- return (6);
- else
- return (7);
- }
- else /* delta_y >= 0 && delta_x < 0 */
- {
- if ((-delta_y / delta_x) > 4)
- return (4);
- else if ((-delta_x / delta_y) > 4)
- return (6);
- else
- return (5);
- }
- }
-
- void pointer_initialise(void)
- {
- /* do nothing in this particular effect */
- }
-
- void pointer_free(void)
- {
- /* do nothing in this particular effect */
- }
-
- void pointer_details (PTBHEffectDetails details)
- {
- strcpy (details->effect_name, POINTER_EFFECT );
- details->is_configurable = FALSE;
- details->init_config_data = 0;
- details->Configure = NULL;
- details->BeginEffect = pointer_begin_effect;
- details->DoEffect = pointer_do_effect;
- details->EndEffect = pointer_end_effect;
- details->LoadCursors = pointer_load_cursor;
- details->SelectCursor = pointer_select_cursor;
- details->InitialiseEffect = pointer_initialise;
- details->FreeEffect = pointer_free;
- details->number_of_cursors = 8;
- }
-
-
- /* ========================================================================== */
- /* == Get number of warp effects exported from this DLL == */
- /* ========================================================================== */
- unsigned short CALLBACK EXPORT_FN BHGetNumberOfEffects (void)
- {
- return (1);
- }
-
- /* ========================================================================== */
- /* == Get effects details - == */
- /* == details points to an array of TBHEffectDetails large enough for == */
- /* == the number of effects given by BHGetNumberOfEffects == */
- /* ========================================================================== */
-
- void CALLBACK EXPORT_FN BHGetEffectsDetails(PTBHEffectDetails details)
- {
- // Simple effect
- pointer_details (&details[0]);
- }
-
-
- /* ========================================================================== */
- /* == LibMain function for DLL entry point == */
- /* ========================================================================== */
-
- int FAR PASCAL LibMain (HINSTANCE hInstance, WORD wDataSeg,
- WORD cbHeapSize, char FAR * cmdLine)
- {
- FXInstance = hInstance;
- return (1);
- }
-
- /* ========================================================================== */
- /* == Windows Exit Procedure == */
- /* ========================================================================== */
-
- int FAR PASCAL WEP (int nParameter)
- {
- return (1);
- }
-
-
-